﻿// Decompiled with JetBrains decompiler
// Type: MCM.LightInject.PropertySelector
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;

#nullable disable
namespace MCM.LightInject
{
  [ExcludeFromCodeCoverage]
  internal class PropertySelector : IPropertySelector
  {
    public IEnumerable<PropertyInfo> Execute(Type type)
    {
      return (IEnumerable<PropertyInfo>) type.GetRuntimeProperties().Where<PropertyInfo>(new Func<PropertyInfo, bool>(this.IsInjectable)).ToList<PropertyInfo>();
    }

    protected virtual bool IsInjectable(PropertyInfo propertyInfo)
    {
      return !PropertySelector.IsReadOnly(propertyInfo);
    }

    private static bool IsReadOnly(PropertyInfo propertyInfo)
    {
      return propertyInfo.SetMethod == (MethodInfo) null || propertyInfo.SetMethod.IsStatic || propertyInfo.SetMethod.IsPrivate || propertyInfo.GetIndexParameters().Length != 0;
    }
  }
}
